package com.swanclouds.redfish.common.redfish;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.swanclouds.model.ModelEntity;

/**
 * ${DESCRIPTION}
 *
 * @author 张立强
 */
public class FruControl implements ModelEntity {

    @JsonProperty("FruControlType")
    private FruControlType fruControlType;

    @JsonProperty("FruID")
    private Integer fruId;

    public FruControl() {
    }

    public FruControl(FruControlType fruControlType, Integer fruId) {
        this.fruControlType = fruControlType;
        this.fruId = fruId;
    }

    public FruControl(String fruControlType, Integer fruId) {
        this.fruControlType = FruControlType.valueOf(fruControlType);
        this.fruId = fruId;
    }

    public FruControlType getFruControlType() {
        return fruControlType;
    }

    public void setFruControlType(FruControlType fruControlType) {
        this.fruControlType = fruControlType;
    }

    public Integer getFruId() {
        return fruId;
    }

    public void setFruId(Integer fruId) {
        this.fruId = fruId;
    }

    @JsonRootName("FruControlType")
    public enum FruControlType implements ModelEntity  {
        On("On","上电"),
        ForceOff("ForceOff","强制下电"),
        ForceRestart("ForceRestart","强制重启"),
        GracefulShutdown("GracefulShutdown","正常下电"),
        ForcePowerCycle("ForcePowerCycle","强制下电再上电"),
        Nmi("Nmi","触发不可屏蔽中断");

        private String code;
        private String description;

        FruControlType(String code) {
            this.code = code;
            this.description = FruControlType.valueOf(code).getDescription();
        }

        FruControlType(String code,String description) {
            this.code = code;
            this.description = description;
        }

        public String getCode() {
            return code;
        }

        public void setCode(String code) {
            this.code = code;
        }

        public String getDescription() {
            return description;
        }

        public void setDescription(String description) {
            this.description = description;
        }

    }
    @JsonRootName("FruID")
    public enum FRUType implements ModelEntity  {
        OS(0,"OS平面"),
        Base(1,"Base平面"),
        Fabric(2,"Fabric平面"),
        PC(3,"PC平面");

        private Integer code;
        private String description;

        FRUType(Integer code) {
            this.code = code;
            this.description = FRUType.valueOf(String.valueOf(code)).getDescription();
        }

        FRUType(Integer code,String description) {
            this.code = code;
            this.description = description;
        }

        public Integer getCode() {
            return code;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getDescription() {
            return description;
        }

        public void setDescription(String description) {
            this.description = description;
        }

    }

    @Override
    public String toString() {
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            return objectMapper.writeValueAsString(this);
        } catch (JsonProcessingException e) {
        }
        return "FruControl{" +
                "fruControlType=" + fruControlType +
                ", fruId=" + fruId +
                '}';
    }
}
